<template>
  <div>
    <el-row>
      <el-col :span="24" align="right">
        <div style="margin-top:10px">
          <el-input style="width:200px" v-model="filters.name" placeholder="请输入事件名称"></el-input>
          <el-select v-model="filters.kind" placeholder="请选择事件类型">
            <el-option :value="1" label="一般事件"></el-option>
            <el-option :value="2" label="重大事件"></el-option>
          </el-select>
          <!-- <el-select v-model="filters.status" placeholder="请输入事件处理状态">
                  <el-option v-for="(v,i) of EventStatus" :key="i" :label="v.sseventStatusTypeName" :value="v.sseventStatusTypeValue"></el-option>
                </el-select> -->
          <el-button type="primary" icon="search" @click="getInfo">搜索</el-button>
          <el-button type="primary" @click="flushAll">刷新</el-button>
        </div>
        <el-row style="margin-top:20px">
          <el-col :span="$store.getters.user.userRole=='超级管理员'?3:0">
            <treeComponent style="margin-top:-52px" @GetNodeValue="GetNodeValue"></treeComponent>
          </el-col>
          <el-col :span="$store.getters.user.userRole=='超级管理员'?21:24">
            <el-table :data="list" border>
              <el-table-column v-for="(v,k,i) in props" :key="v.id" :label="labels[i]" align="center">
                <template scope="scope">
                  <span v-if="k==='sex'">
                    {{scope.row[k]==1?'男':'女'}}
                  </span>
                  <span v-else-if="k=='eventKind'">
                    {{scope.row[k]==1?'一般事件':'重大事件'}}
                  </span>
                  <span v-else>
                    {{scope.row[k]}}
                  </span>
                </template>
              </el-table-column>
              <el-table-column label="操作" width="200" align="center">
                <template scope="scope">
                  <el-button size="small" v-if="scope.row.eventStatusTypeValue=='06'||scope.row.eventStatusTypeValue=='08'" type="primary"
                    @click="eventReview(scope.row.eventID)">审核事件</el-button>
                  <el-button type="text" @click="ckDetail(scope.row.eventID)">查看详情</el-button>
                </template>
              </el-table-column>
            </el-table>
             <el-pagination style="margin-top:10px;float:right" layout="prev, pager, next" :total="totalInfo"  @current-change="handleCurrentChange">
            </el-pagination>
          </el-col>
        </el-row>
      </el-col>
    </el-row>
    <el-dialog title="事件审核" :visible.sync="visible">
      <el-form :model="form" label-width="220px">
        <el-form-item label="受理人" style="width:600px">
          <el-input disabled v-model="form.checkedUserID" placeholder=""></el-input>
        </el-form-item>
        <el-form-item label="审核时间">
          <el-date-picker v-model="form.checkedTime" placeholder=""></el-date-picker>
        </el-form-item>
        <el-form-item label="审核结果">
          <el-radio-group v-model="form.checkedResult">
            <el-radio :label="1">通过</el-radio>
            <el-radio :label="0">不通过</el-radio>
          </el-radio-group>
        </el-form-item>
        <el-form-item label="备注" style="width:600px">
          <el-input type="textarea" v-model="form.remark" placeholder=""></el-input>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" @click="success()">确认</el-button>
          <el-button type="warning" @click="visible = false">取消审核</el-button>
        </el-form-item>
      </el-form>
    </el-dialog>

    <el-dialog top="5%" title="查看详情" :visible.sync="visible2">
      <info :id="id"></info>
    </el-dialog>
  </div>
</template>

<script>
  import treeComponent from "../../components/common/treeComponent";
  import * as api from "../../api/netGridManage";
  import * as api2 from "../../api/securityManage";
  import info from "./netEventInfo";

  export default {
    components: {
      treeComponent: treeComponent,
      info: info
    },
    data() {
      return {
        visible: false,
        filters: {
          id: 5,
          name: null,
          kind: null,
          netGridID: null,
          status: null,
          page: 1,
          pageSize: 10
        },
        EventStatus: [],
        form: {
          eventID: "", //,
          checkedUserID: 5, //        bigint,
          checkedTime: "", //          datetime,
          checkedResult: "", //        int,
          remark: "" //              varchar(500),
        },
        list: [{
          eventID: "", //            bigint not null auto_increment,
          eventName: "", //           '事件名称',
          eventKind: "", //           '事件性质，如1=一般事件；2=重大事件；等',
          eventTypeValue: "", //      '事件类型，如杀人、放火、抢劫等',
          eventContent: "", //         ,
          eventStartDateTime: "", //   datetime,
          // eventEndDateTime:'',//     datetime,
          eventHappenLongitude: "", // '地理经度信息',
          eventHappenLatitude: "", //  comment '地理纬度信息',
          eventStatusTypeValue: "", //   '当前事件处理的最新状态',
          currentRemarks: "", //        ,
          currentResponsiblePersonCertID: "", // '当前经办人员身份证号',
          currentResponsiblePersonName: "", //'当前经办人员姓名',
          currentResponsiblePersonContact: "", //'经办人员联系方式',
          netGridID: "" // ,
        }],
        totalInfo: 0,
        props: {
          eventName: "",
          eventKind: "", //               '事件性质，如1=一般事件；2=重大事件；等',
          eventTypeName: "", //          '事件类型，如杀人、放火、抢劫等',
          eventStatusTypeName: "", //     '当前事件处理的最新状态',
          eventStartDateTime: '',
          netGridName: "" //所属网格
        },
        labels: [
          "事件名称",
          "事件性质",
          "事件类型",
          "事件处理状态",
          "发生日期",
          "所属网格"
        ],
        currentPage: 1,
        id: '01',
        visible2: false
      };
    },
    methods: {
      success() {
        let type = this.form.checkedResult == 1 ? "07" : "08";
        api.addNetGridEventChecked(this.form).then(res => {
          if (res.code == 200) {
            this.$message({
              type: "success",
              message: "审核信息上传成功!"
            });
            api.updateNetGridEventStatus(type, this.form.eventID).then(res => {
              if (res.code == 200) {
                this.$message({
                  type: "success",
                  message: "事件审核更新成功!"
                });
                this.getInfo()
                this.visible = false
              } else {
                this.$message({
                  type: "error",
                  message: "事件审核更新失败!"
                });
              }
            });
          }
        });
      },
      eventReview(id) {
        this.form.eventID = id;
        this.visible = true;
      },
      flushAll() {
        this.filters.name = this.filters.kind = this.filters.netGridID = this.filters.status = null;
        this.getInfo();
      },
      handleCurrentChange(val) {
        this.filters.page = val;
        this.getInfo();
      },
      ckDetail(id) {
        this.id = id;
        this.visible2 = true;
      },
      addNewRecord() {
        this.$router.push("add");
      },
      GetNodeValue(val) {
        this.filters.netGridID = val;
        this.getInfo();
      },
      editEvent(id) {
        this.$router.push({
          path: "editReview",
          query: {
            id: id
          }
        });
      },
      getInfo() {
        if (this.$store.getters.user.userRole != '超级管理员')
          this.filters.netGridID = this.$store.getters.user.netGridID
        api.getNetGridEventAuditorQuery(this.filters).then(res => {
          this.list = res.data.vos;
          this.totalInfo = res.data.page.totalCount;
        });
        this.filters.name = this.filters.kind = this.filters.netGridID = this.filters.status = null;

      }
    },
    mounted() {
      this.form.checkedUserID = this.$store.getters.user.userID
      this.filters.id = this.$store.getters.user.userID
      this.getInfo();
      api2.getSSEventCode().then(res => {
        this.EventStatus = res.data.EventStatusType
      })
    }
  };

</script>


<style scoped>


</style>
